Skip to content

Upgrade bundling #2187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 1, 2017
Merged

Upgrade bundling #2187

merged 5 commits into from
Dec 1, 2017

Conversation

dy
Copy link
Contributor

@dy dy commented Nov 28, 2017

  • introduces minify-stream instead of uglifyjs2 - less errors, better options
  • removes patch_minified (seems that uglify-es fixes that since tests pass)
  • introduces bubleify to handle ES6 dependencies

@dy dy requested a review from etpinard November 28, 2017 23:08
},

bubleifyOptions: {
target: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. We have to target browsers waaaaaaaay older than that. Can bubleify guarantee to output code that IE11 understands?

Copy link
Contributor Author

@dy dy Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard that is the best bubleify can do, it is targeted only for ES6 → ES5, not ES5 → ES3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Well that won't work then. plotly.js needs to be pure ES5.

Copy link
Contributor Author

@dy dy Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard that is pure ES5, same as what we have now. target flag only indicates what new ES6 features are supported by target environment to avoid their handling, eg. some browsers have Object.assign or arrow functions, but do not do power a ** b etc, so since we indicate oldest target available in buble, we make sure we get pure ES5.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put these config options in the package.json instead, so that all consumers bundling with browserify or webpack+ify-loader get the same results as us in our dist/?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the output bundle be minified by plain-old uglify-js? e.g. does

browserify -t bubleify src/plotly.js | uglify-js > bundle.js

work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this target option. I find it pretty confusing. Could we instead manually list all the transforms we want turned on?

@etpinard
Copy link
Contributor

@dfcreative can you run npm run bundle && git diff -- dist/README.md and paste a screenshot of the diff to get an idea of how the new minifiers perform?

@dy
Copy link
Contributor Author

dy commented Nov 28, 2017

image

How serious is that? Should I try to squeeze that more?

Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How serious is that? Should I try to squeeze that more?

I think so. That's an awful lot extra bytes. I see that minify-stream is using uglify-es. Is there a way to make it more agressively minify things? Or maybe we should just use plain-old uglify-js


Oh well, after thinking about this some more, transpiling our deps down to ES5 is inevitable if we want to stay up-to-date will latest development. So thanks for getting the ball rolling @dfcreative

},

bubleifyOptions: {
target: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put these config options in the package.json instead, so that all consumers bundling with browserify or webpack+ify-loader get the same results as us in our dist/?

},

bubleifyOptions: {
target: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the output bundle be minified by plain-old uglify-js? e.g. does

browserify -t bubleify src/plotly.js | uglify-js > bundle.js

work?

},

bubleifyOptions: {
target: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this target option. I find it pretty confusing. Could we instead manually list all the transforms we want turned on?

*
*/
module.exports = function patchMinified(minifiedCode) {
return minifiedCode.replace(PATTERN, NEW_SUBSTR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the hackiest thing in plotly.js at the moment. Good riddance 🎉

@@ -1,6 +1,6 @@
var path = require('path');
var fs = require('fs');
var spawn = require('child_process').spawn;
var spawn = require('cross-spawn');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha nice catch. That's for that spawn('npm', ['ls', '--json', '--only', 'prod']); statement below - which will be obsolete when we switch to npm@5 as the new package-lock.json file will do that same as the current dist/npm-ls.json.

@dy
Copy link
Contributor Author

dy commented Nov 29, 2017

Actually that diff is not that scary, the actual master has the same size:
image
It is just the dist/README.md we have is old.

@etpinard
Copy link
Contributor

It is just the dist/README.md we have is old.

Ha. I see. Yeah we have a bunch of new things in master that didn't get released yet. 👌

@etpinard
Copy link
Contributor

For reference:

on the latest master:

image

off this branch:

image

Lovely ❤️

@etpinard
Copy link
Contributor

Great PR. Thanks for doing this @dfcreative

Getting rid of patch_minified.js well worth swapping uglify-js for uglify-es.

Merge away 💃

@etpinard etpinard merged commit 579d3cc into master Dec 1, 2017
@etpinard etpinard deleted the bundle-up branch December 1, 2017 21:15
@ndabAP
Copy link

ndabAP commented Jan 12, 2018

My Webpack code splitted asset increased by approximately 200 kilobytes after updating to 1.32.0.

@etpinard
Copy link
Contributor

That's because we added a lot of features (sorry 😉 ).

But still 200 kB seems larger than the worse case increase (see bundle size changes from 1.31.2 to 1.32.0 here). Perhaps something is off. Would you care to share a reproducible example of your bundle setup and config?

@ndabAP
Copy link

ndabAP commented Jan 12, 2018

That's because we added a lot of features

Got it. Would still be nice to be more selective about the features. It would be cool to have the possibility to omit special features like chart zooming, saving as picture or maybe animations to get a smaller package.

Would you care to share a reproducible example of your bundle setup and config?

Unfortunately, my asset has a lot of Vue.js related stuff in it. It would take weeks to sort it out ;) It's not exactly 200 kilobytes, though.

@etpinard
Copy link
Contributor

Would still be nice to be more selective about the features.

Yep, we know. That'll have to wait for v2 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants